<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        .box{width: 200px;height: 200px;background: pink}
    </style>
</head>
<body>
    <div class="box"></div>
</body>
<script>
    var obox = document.querySelector(".box")

    obox.onclick = function(a){
        var e = a || window.event;
        console.log(e);
    }

    // 键盘事件只能加给有焦点的元素

    document.onkeydown = function(){
        console.log(2)
    }
</script>
</html>